﻿Public Class FrmPrincipal

#Region "FrmPrincipal"

    Private Property btnSelected As String

    Private Sub FrmPrincipal_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'GetFitDataSet.Usuarios' table. You can move, or remove it, as needed.
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None 'Elimina los bordes del formulario
        Me.WindowState = FormWindowState.Maximized 'Maximiza el formulario

        For Each panel As Panel In paneMenu.Controls.OfType(Of Panel)()
            AddHandler panel.MouseDown,
            Function(senderObj, args) Seleccionar(panel)
            AddHandler panel.MouseHover,
            Function(senderObj, args) Sombrear(panel)
            AddHandler panel.Click,
            Function(senderObj, args) DarFuncion(panel)
            For Each ctr As Control In panel.Controls
                AddHandler ctr.MouseDown,
                Function(senderObj, args) Seleccionar(panel)
                AddHandler ctr.MouseHover,
                Function(senderObj, args) Sombrear(panel)
                AddHandler ctr.Click,
                Function(senderObj, args) DarFuncion(panel)
            Next
        Next
    End Sub

    Private Function Seleccionar(ppanel As Panel) As Object
        For Each panel As Panel In paneMenu.Controls.OfType(Of Panel)()
            panel.BackColor = Color.FromArgb(33, 33, 33)
        Next
        ppanel.BackColor = Color.FromArgb(237, 107, 0)
        btnSelected = ppanel.Name
        Return ppanel
    End Function

    Private Function Sombrear(ppanel As Panel) As Object
        For Each panel As Panel In paneMenu.Controls.OfType(Of Panel)()
            If panel.Name <> btnSelected Then
                panel.BackColor = Color.FromArgb(33, 33, 33)
            End If
        Next
        If ppanel.Name <> btnSelected Then
            ppanel.BackColor = Color.FromArgb(61, 61, 61)
        End If
        Return ppanel
    End Function

    Private Function DarFuncion(ppanel As Panel) As Object
        paneForm.Controls.Clear()
        Dim frm As New Control

        Select Case ppanel.Name
            Case "btnClientes"
                ' Aqui se pone la funcion del boton clientes 
                ' frm = New frmConsultarClientes
            Case "btnRoles"
                ' Aqui se pone la funcion del boton roles
            Case "btnEjercicios"
                ' Aqui se pone la funcion del boton ejercicios
                frm = New FrmConsultarEjercicios
            Case "btnMusculos"
                ' Aqui se pone la funcion del boton musculos
            Case "btnMaquinas"
                ' Aqui se pone la funcion del boton maquinas
            Case "btnConfiguracion"
                ' Aqui se pone la funcion del boton configuracion
            Case "btnFuncionarios"
                ' Aqui se pone la funcion del boton funcionarios
            Case "btnBitacoras"
                ' Aqui se pone la funcion del boton bitacoras
            Case "btnSalir"
                Application.Exit()
        End Select
        frm.Dock = DockStyle.Fill
        paneForm.Controls.Add(frm)
        Return ppanel
    End Function
#End Region

#Region "btnMenu"
    Private Sub btnMenu_Click(sender As Object, e As EventArgs) Handles btnMenu.Click
        If paneMenu.Width = 70 Then 'Si el panel del menu es igual a 70 se agranda

            paneMenu.Width = 304  'Agranda el panel del menu a 304
            picLogo.Show() 'Se muestra la imagen del logo
            btnMenu.Location = New System.Drawing.Point(241, 54)


        Else 'Si el menu esta agrandado

            paneMenu.Width = 70 'Le disminuye el tamano
            picLogo.Hide() 'Esconde la imagen del logo
            btnMenu.Location = New System.Drawing.Point(18, 40)

        End If
    End Sub

    Private Sub btnMenu_MouseHover(sender As Object, e As EventArgs) Handles btnMenu.MouseHover
        btnMenu.Image = My.Resources.menu_hover 'Obtiene la imagen de la carpeta Resources y la asigna
    End Sub

    Private Sub btnMenu_MouseLeave(sender As Object, e As EventArgs) Handles btnMenu.MouseLeave
        btnMenu.Image = My.Resources.menu_leave 'Obtiene la imagen de la carpeta Resources y la asigna
    End Sub
#End Region

  

 
End Class


